<template>
  <view class="setting">
    <view class="userInfo">
      <view class="logo"></view>
      <view class="info">
        <view>{{userInfo.c_real_user_name}} · {{ userInfo.c_user_name }}</view>
      </view>
    </view>
    <nut-cell-group title="" desc="">
      <nut-cell title="个人资料" is-link  @click="gotoPage('/pages/userinfo/index')">
      </nut-cell>
      <nut-cell title="修改密码" is-link @click="gotoPage('/pages/changePwd/index')">
      </nut-cell>
    </nut-cell-group>
    <view class="loginBtn">
      <nut-button type="success" block color="linear-gradient(to right, #ff6034, #ee0a24)" @click="userLogOut">退出登录</nut-button>
    </view>
  </view>
</template>

<script setup>
import './index.scss';
import { ref } from 'vue';
import Taro, {useDidShow} from '@tarojs/taro'
import { My } from '@nutui/icons-vue-taro'

const userInfo = ref({})

const gotoPage = (path) => {
  Taro.navigateTo({
    url: path
  })
}
const userLogOut = () => {
  Taro.showModal({
      title: '温馨提示',
      confirmText: '确认',
      content: '您确认登出系统吗？',
      success: (res) => {
        if (res.confirm) {
          Taro.removeStorage({
            key: 'token',
          })
          Taro.removeStorage({
            key: 'userInfo',
          })
          Taro.reLaunch({
            url: '/pages/login/index'
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
}
useDidShow(() => {
  var userInfoSync = Taro.getStorageSync('userInfo')
  userInfo.value = userInfoSync ? JSON.parse(userInfoSync) : {}
  console.log(userInfo.value)
})
</script>

<style>
</style>